package test;

import datastruct.树.线段树.AbstractNode;
import datastruct.树.线段树.nodes.IntSumWithModNode;
import javafx.util.Pair;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author xushenbao
 * @desc 添加描述
 * @create 2020/11/10
 */
public class Poj3468 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        List<Pair<Integer,Integer>> indexValue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            indexValue.add(new Pair<>(i+1,scanner.nextInt()));
        }
        IntSumWithModNode abstractNode = new IntSumWithModNode();


        IntSumWithModNode tmp = abstractNode.treeBuild(indexValue);
        for (int i = 0; i < m; i++) {
            String s = scanner.next();
            if (s.equals("Q")) {
                System.out.println(tmp.query(IntSumWithModNode.Queries.SUM, scanner.nextInt(), scanner.nextInt()));
            }
            if ("C".equals(s)) {
                int l=scanner.nextInt();
                int r=scanner.nextInt();
                int v=scanner.nextInt();
                tmp.operate(IntSumWithModNode.Operate.CHANGE, v,l,r);
            }
        }
    }

}
